package io.geekidea.boot.generator.enums;

import java.util.HashMap;
import java.util.Map;

/**
 * 请求映射风格 1：boot设计风格，2：restful设计风格，3：全部小写设计风格，4：中横线设计风格，5：下划线设计风格
 *
 * @author geekidea
 * @date 2024/1/11
 **/
public enum RequestMappingStyle {

    BOOT(1, "boot设计风格" ),
    RESTFUL(2, "restful设计风格" ),
    SMALL_LETTER(3, "全部小写字母设计风格" ),
    HYPHEN(4, "中横线连接符设计风格" ),
    UNDERLINE(5, "下划线设计风格" );

    private Integer code;

    private String desc;

    RequestMappingStyle(Integer code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public Integer getCode() {
        return code;
    }

    public String getDesc() {
        return desc;
    }

    private static final Map<Integer, RequestMappingStyle> map = new HashMap<>();

    static {
        for (RequestMappingStyle style : values()) {
            map.put(style.code, style);
        }
    }

    public static RequestMappingStyle get(Integer code) {
        RequestMappingStyle style = map.get(code);
        if (style == null) {
            return BOOT;
        }
        return style;
    }

    public static String getDesc(Integer code) {
        RequestMappingStyle style = get(code);
        if (style == null) {
            return null;
        }
        return style.getDesc();
    }

}
